import request from "@/utils/request";
import type { AxiosPromise } from "axios";
import type { CategoryForm, CategoryQuery, CategoryVO } from "./types";

export const listCategory = (query?: CategoryQuery): AxiosPromise<CategoryVO[]> => {
  return request({
    url: "/system/category/list",
    method: "get",
    params: query
  });
};

export const addCategory = (data: CategoryForm) => {
  return request({
    url: "/system/category",
    method: "post",
    data: data
  });
};

export const updateCategory = (data: CategoryForm) => {
  return request({
    url: "/system/category",
    method: "put",
    data: data
  });
};

export const delCategory = (categoryId: number | string) => {
  return request({
    url: "/system/category/" + categoryId,
    method: "delete"
  });
};
